<?php
namespace app\admin\controller;

use app\admin\library\builder\components\Form;
use app\admin\library\builder\Layout;
use think\Controller;

class Index extends Controller
{
    public function index()
    {
//        $container = new Container();
//        $container->child();
        $lay = new Layout();
        $lay->pushComponents('form', [
            'fields'=>[
                'name'=>[
                    'text'=>'名称',
                    'placeholder'=>'15'
                ],
                'pass'=>[
                    'type'=>'password',
                    'text'=>'密码',
                ],
                'title'=>'标题',
                'gender'=>[
                    'text'=>'性别',
                    'type'=>'radio',
                    'value'=>0,
                    'options'=>[
                        0=>'女',
                        1=>'男'
                    ]
                ],
                'city'=>[
                    'text'=>'城市',
                    'type'=>'select',
                    'value'=>0,
                    'options'=>[
                        0=>'北京',
                        1=>'上海'
                    ]
                ],
                'checkbox'=>[
                    'text'=>'复选框',
                    'type'=>'checkbox',
                    'value'=>0,
                    'skin'=>'primary',
                    'options'=>[
                        0=>'写作',
                        1=>'发呆'
                    ]
                ],
                'textarea'=>[
                    'text'=>'文本域',
                    'type'=>'textarea',
                ]
            ],
            'validate'=>[
                'name'=>[
                    'required'=>true,
                ]
            ],
            'button'=>[
                'submit'=>[
                    'text'=>'提交'
                ]
            ],
            'method'=>'post',
            // 表单提交回调
            'callback'=>function ($success, $fail) {
                return $success(['msg'=>'提交成功', 'url'=>url('article/index')]);
            }
        ]);
        return $lay->render();
    }

}
